package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 风险记录结果
 *
 * @author ytche
 * @date 2017年8月2日
 *
 */
@Entity
@JsonApiResource(type = "riskRecordResult")
@Table(name = "TNB_RISK_RECORD_RESULT")
public class RiskRecordResult extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Customer customer;
	private Integer recordTime;
	private RiskRecordModel model;
	private Set<RiskFieldResult> results;
	private Employee user;

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "customer_id")
	@JsonApiIncludeByDefault
	@JsonApiToOne
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "record_time")
	public Integer getRecordTime() {
		return recordTime;
	}

	public void setRecordTime(Integer recordTime) {
		this.recordTime = recordTime;
	}

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH, mappedBy = "recordResult")
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Set<RiskFieldResult> getResults() {
		return results;
	}

	public void setResults(Set<RiskFieldResult> results) {
		this.results = results;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "model_id")
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public RiskRecordModel getModel() {
		return model;
	}

	public void setModel(RiskRecordModel model) {
		this.model = model;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "employee_id")
	@JsonApiToOne
	@JsonApiIncludeByDefault
	public Employee getUser() {
		return user;
	}

	public void setUser(Employee user) {
		this.user = user;
	}
}
